package com.all.ui;

import com.all.ui.adapter.HomePagerAdapter;

import android.annotation.SuppressLint;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

public class HomeActivity extends FragmentActivity implements OnClickListener {

	/** 底部栏 **/
	TextView mTextMe = null;
	TextView mTextWork = null;
	TextView mTextKnow = null;
	
	private ViewPager mViewPager;
	private HomePagerAdapter mHomePagerAdater;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_home);
		
		init();
	}
	
	private void init() {
		// TODO Auto-generated method stub
		mTextMe = (TextView) findViewById(R.id.main_footer_me);
		mTextKnow = (TextView) findViewById(R.id.main_footer_know);
		mTextWork = (TextView) findViewById(R.id.main_footer_work);
		
		mTextMe.setOnClickListener(this);
		mTextWork.setOnClickListener(this);
		mTextKnow.setOnClickListener(this);
		
		mViewPager = (ViewPager) findViewById(R.id.viewPager);
		mHomePagerAdater = new HomePagerAdapter(getSupportFragmentManager());
		mViewPager.setAdapter(mHomePagerAdater);
		mViewPager.setOffscreenPageLimit(2);
	}

	@SuppressLint("CommitTransaction")
	@Override
	public void onClick(View arg) {
		// TODO Auto-generated method stub
		if (arg.equals(mTextMe)) {
			mViewPager.setCurrentItem(0);
		}else if (arg.equals(mTextWork)) {
			mViewPager.setCurrentItem(1);
		} else if (arg.equals(mTextKnow)) {
			mViewPager.setCurrentItem(2);
		} 
	}

}
